﻿--[[
   @brief    tips_reveive
   @author   jadonsun
   @version  1.0
   @date     2015-06-17
--]]

tips_reveive_common = {
    tips_qos_id = ierd_tgp.adapt_for_imports.qos.Qos_kind.kLocalGameVersion;
    open_link_service = "i_service_open_link";
}

function tips_reveive_common.tips_qos(main_action, sub_action, tip_data, ret_data)
    base_utility.log("[tips_reveive_common] qos report for tips");
    local report_data = ierd_tgp.tpf_ui.LuaQosDataEx:new();
    local pv_data = {};

    if tip_data == nil then
        return;
    end;

    if nil ~= report_data then
        if tip_data.game_id ~= nil and tip_data.game_id ~= "" then
            pv_data["game_id"] = tip_data.game_id;
        else
            pv_data["game_id"] = 0;
        end;
        if tip_data.tips_sub_type ~= nil and tip_data.tips_sub_type ~= "" then
            pv_data["tips_type"] = tip_data.tips_sub_type;
        end;

        -- 登录广告tips，需要上报tips id，这里加上tips id
        if tip_data.task_id ~= nil and tip_data.task_id > 0 then
            pv_data["tips_id"] = tip_data.task_id;
        end;

        if ret_data ~= nil and ret_data.close_type ~= nil
                and ret_data.close_type ~= "" then
            pv_data["click_area"] = ret_data.close_type;
        end;
        report_data.oc_type    = 1;
        report_data.qos_kind = tips_reveive_common.tips_qos_id;
        report_data.str_action = main_action;
        report_data.str_type = sub_action;
        report_data.str_json = base_utility.table_to_json(pv_data);
        base_utility.log("[tips_reveive_common], qos, qos_kind="..report_data.qos_kind.."; str_action="..report_data.str_action.."; sub_action="..report_data.str_type.."; str_json="..report_data.str_json);
        base_utility.lua_qos_ex(report_data);
        report_data:delete();
    end
end

tip_type_constant =
{
    MAIN_TYPE_NORMAL = 0;
    MAIN_TYPE_BUBBLE = 1;
    MAIN_TYPE_WEB = 2;
    ICON_TYPE_SQUARE = 1;
    ICON_TYPE_CIRCULAR = 0;
    BUBBLE_ICON_TYPE_BUTTON = 2;
    BUBBLE_ICON_TYPE_RECTANGLE = 1;
    BUBBLE_ICON_TYPE_SQUARE = 0;

    sub_type_update_result = 3001;
    sub_type_preupdate_begin = 3002;
    sub_type_preupdate_end = 3003;
    sub_type_autoupdate_begin = 3004;
    sub_type_install_finish = 3005;
    sub_type_live = 3006;
    sub_type_video = 3007;
    sub_type_server_normal = 3008;
    sub_type_server_wantplay = 3009;
    sub_type_gamelive = 3011;
    sub_type_wegame_online = 3012;
    sub_type_game_online = 3013;
    sub_type_wegame_level_up = 3014;
    sub_type_subscription_state = 3015;
}

-- 游戏更新相关tips
gameupdate_tips_control = {
    show_update_tip_list = {};
    switch_branch_game_id = 0;
    switch_branch_state = 0;
    switch_branch_id = 0;
    switch_branch_name = "";
}


function gameupdate_tips_control.init()
    comm_center.listen_broadcast("i_broadcast_update_result_close", gameupdate_tips_control.on_update_result_close);
    comm_center.listen_broadcast("i_broadcast_preupdate_begin_close",
        gameupdate_tips_control.on_preupdate_begin_close);
    comm_center.listen_broadcast("i_broadcast_preupdate_result_close",
        gameupdate_tips_control.on_preupdate_result_close);
    comm_center.listen_broadcast("i_broadcast_autoupdate_begin_close",
        gameupdate_tips_control.on_autoupdate_begin_close);
    comm_center.listen_broadcast("i_broadcast_install_finish_close",
        gameupdate_tips_control.on_install_finish_close);
end

function gameupdate_tips_control.add_update_tip(tip_data)
    local cur_length = #(gameupdate_tips_control.show_update_tip_list);
    table.insert(gameupdate_tips_control.show_update_tip_list,
                    cur_length + 1, tip_data);
end

function gameupdate_tips_control.remove_update_tip(tip_id)
    local cur_length = #(gameupdate_tips_control.show_update_tip_list);
    local remove_index = 0;
    for index = 1, cur_length do
        local temp_tip_data = gameupdate_tips_control.show_update_tip_list[index];
        if temp_tip_data.id == tip_id then
            remove_index = index;
            break;
        end;
    end;
    if remove_index > 0 then
        table.remove(gameupdate_tips_control.show_update_tip_list, remove_index);
    end;
end

function gameupdate_tips_control.find_update_tip(tip_id)
    local cur_length = #(gameupdate_tips_control.show_update_tip_list);
    local find_tip_data = nil;
    for index = 1, cur_length do
        local temp_tip_data = gameupdate_tips_control.show_update_tip_list[index];
        if temp_tip_data.id == tip_id then
            find_tip_data = gameupdate_tips_control.show_update_tip_list[index];
            break;
        end;
    end;
    return find_tip_data;
end

function gameupdate_tips_control.on_game_switch_branch(content_tbl)
    if content_tbl ~= nil then
        base_utility.log("[gameupdate_tips_control] switch branch happened, gameid=".. content_tbl.game_id);
        gameupdate_tips_control.switch_branch_game_id = content_tbl.game_id;
        gameupdate_tips_control.switch_branch_state = content_tbl.change_branch;
        gameupdate_tips_control.switch_branch_id = content_tbl.branch_id;
        gameupdate_tips_control.switch_branch_name = content_tbl.branch_name;
    end;
end
-- 游戏更新成功事件
function  gameupdate_tips_control.on_game_update_result(event_id, json_str)
    base_utility.log("[gameupdate_tips_control]on_game_update_result, " .. json_str);
    local result = base_utility.json_to_table(json_str);

    if result.result ~= 0 then
        base_utility.log("[gameupdate_tips_control][on_game_update_result]result is NOT success");
        return;
    end;
    -- 准备要显示的数据
    local params = {};
    params.current_game_id = result.game_id;
    params.current_version = result.ver;
    local base_info = banner_model.get_game_base_info(result.game_id);
    if base_info == nil then        
        base_utility.log("[gameupdate_tips_control]base_info is nil, game_id:" .. result.game_id, true);
        return;
    end;
    params.game_name = base_info.name;
    -- 获得横版海报
    params.game_img_url = base_info.poster_url;
    -- 没明白这里为啥要打印这个？暂时保留吧
    local game_state = banner_model.get_game_state(result.game_id);
    if game_state == nil then
        base_utility.log("[gameupdate_tips_control]game_state is nil, game_id:" .. result.game_id, true);
    end;

    -- 整理要显示的内容，发送给tips管理器显示
    gameupdate_tips_control.show_update_success_tips(params);
end

-- 显示更新成功tips
function gameupdate_tips_control.show_update_success_tips(params)
    local tip_data = {};
    local is_switch = false;
    if gameupdate_tips_control.switch_branch_game_id ~= nil and 
        gameupdate_tips_control.switch_branch_game_id == params.current_game_id and
        gameupdate_tips_control.switch_branch_state == 1 then
        is_switch = true;
    else
        is_switch = false;
    end;
    tip_data.id = os.time();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_BUBBLE;
    tip_data.tips_sub_type = tip_type_constant.sub_type_update_result;
    if params.game_img_url ~= nil then
        tip_data.tips_icon = params.game_img_url;  -- 添加获取的游戏头像
    end;
    local third_title = "";
    if is_switch == true then
        tip_data.main_title = LoadStr(ID_TIPS_SWITCH_BRANCH_MAIN);
        if gameupdate_tips_control.switch_branch_name ~= nil then
            third_title = third_title..LoadStr(ID_TIPS_SWITCH_BRANCH_SUB_1) .. gameupdate_tips_control.switch_branch_name .. LoadStr(ID_TIPS_SWITCH_BRANCH_SUB_2);
        end;
    else
        tip_data.main_title = LoadStr(ID_TIPS_UPDATE_1);
        if params.current_version ~= nil then
            third_title = third_title..LoadStr(ID_TIPS_UPDATE_2) .. params.current_version .. LoadStr(ID_TIPS_UPDATE_3);
        end;
    end;
    tip_data.sub_title = params.game_name;

    if third_title ~= "" then
        local max_text_len = 24;
        local text_len = base_utility.cal_str_width(third_title);
        if text_len > max_text_len then
            local text_for_ui = U8toCUIStrn(third_title, max_text_len, 1);
            third_title = CUIStrtoU8(text_for_ui);
        end
        tip_data.third_title = third_title;
    end;
    if params.current_game_id ~= nil then
        local jump_url="";
        jump_url = '{"type":"landing","game_id":'..params.current_game_id..'}';
        
        tip_data.win_click_url = jump_url;
    end;
    tip_data.tips_type_bubble = 1;
    tip_data.close_service = "i_broadcast_update_result_close";
    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);
    gameupdate_tips_control.add_update_tip(tip_data);
    -- 数据上报
    tip_data.game_id = params.current_game_id;
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_show", tip_data);
    if is_switch == true then
        -- 清空下
        gameupdate_tips_control.switch_branch_game_id = 0;
        gameupdate_tips_control.switch_branch_state = 0;
        gameupdate_tips_control.switch_branch_id = 0;
    end;
end

function gameupdate_tips_control.on_update_result_close(tip_ret_tbl)

    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gameupdate_tips_control.find_update_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    gameupdate_tips_control.remove_update_tip(tip_ret_tbl.id);
end


-- 游戏预更新开始事件
function gameupdate_tips_control.on_game_preupdate_begin(event, json_str)
    base_utility.log("[gameupdate_tips_control]on_game_preupdate_begin" .. json_str);
    local result = base_utility.json_to_table(json_str);
    if result.game_id == nil then
        base_utility.log("[gameupdate_tips_control]preupdate begin,game id is nil");
    end;
    local params = {};
    params.cur_game_id = result.game_id;
    local base_info = banner_model.get_game_base_info(result.game_id);
    if base_info == nil then
        base_utility.log("[gameupdate_tips_control]base_info is nil, game_id:" .. result.game_id, true);
        return;
    end;
    params.cur_game_name = base_info.name;
    params.cur_game_img_url = base_info.poster_url;
    -- 判断当前是否有预更新tips正在显示中，如果有，则不显示了，因为预更新开始会发送多次消息过来，会导致弹出多个相同的tips，这里做下过滤 show_update_tip_list
    local has_show = false;
    for index = 1, #(gameupdate_tips_control.show_update_tip_list) do
        local tip_data = gameupdate_tips_control.show_update_tip_list[index];
        if tip_data.game_id == params.cur_game_id and tip_data.tips_sub_type == tip_type_constant.sub_type_preupdate_begin then
            has_show = true;
            break;
        end;
    end;
    if has_show == true then
        return;
    end;

    gameupdate_tips_control.show_preupdate_begin_tips(params);
end

-- 显示预更新开始tips
function gameupdate_tips_control.show_preupdate_begin_tips(params)
    local tip_data = {};
    tip_data.id = os.time();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_BUBBLE;
    tip_data.tips_sub_type = tip_type_constant.sub_type_preupdate_begin;
    if params.cur_game_img_url ~= nil then
        tip_data.tips_icon = params.cur_game_img_url;  -- 添加获取的游戏头像
    end;
    
    tip_data.main_title = LoadStr(ID_TIPS_PREUPDATE_BEGIN);
    tip_data.sub_title = params.cur_game_name;
    tip_data.win_click_url = '{"type":"tools","sub_page":"AUTO_UPDATE"}';
    tip_data.tips_type_bubble = tip_type_constant.BUBBLE_ICON_TYPE_RECTANGLE;
    tip_data.close_service = "i_broadcast_preupdate_begin_close";
    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);
    gameupdate_tips_control.add_update_tip(tip_data);
    -- 数据上报
    tip_data.game_id = params.cur_game_id;
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_show", tip_data);
end

function gameupdate_tips_control.on_preupdate_begin_close(tip_ret_tbl)

    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gameupdate_tips_control.find_update_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    gameupdate_tips_control.remove_update_tip(tip_ret_tbl.id);
end

-- 游戏预更新成功事件
function  gameupdate_tips_control.on_game_preupdate_result(event_id, json_str)
    base_utility.log("[gameupdate_tips_control]on_game_preupdate_result" .. json_str);
    local result = base_utility.json_to_table(json_str);

    if result.result ~= 0 then
        base_utility.log("[gameupdate_tips_control][on_game_update_result]result is NOT success");
        return;
    end

    local params = {};
    params.cur_game_id = result.game_id;
    params.cur_version = result.ver;
    local base_info = banner_model.get_game_base_info(result.game_id);
    local game_state = banner_model.get_game_state(result.game_id);

    if base_info == nil then
        base_utility.log("[gameupdate_tips_control]base_info is nil, game_id:" .. result.game_id, true);
        return;
    end;
    params.cur_game_name = base_info.name;
    params.cur_game_img_url = base_info.poster_url;
    params.download_time_sum = result.download_time_sum;
    if game_state == nil then
        base_utility.log("[gameupdate_tips_control]game_state is nil, game_id:" .. result.game_id, true);
    end;

    -- 整理要显示的内容，发送给tips管理器显示
    gameupdate_tips_control.show_preupdate_success_tips(params);
end

-- 显示预更新成功tips
function gameupdate_tips_control.show_preupdate_success_tips(params)
    local tip_data = {};
    tip_data.id = os.time();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_BUBBLE;
    tip_data.tips_sub_type = tip_type_constant.sub_type_preupdate_end;
    if params.cur_game_img_url ~= nil then
        tip_data.tips_icon = params.cur_game_img_url;  -- 添加获取的游戏头像
    end;
    
    tip_data.main_title = LoadStr(ID_TIPS_PREUPDATE_END_1);
    tip_data.sub_title = params.cur_game_name;
    local third_title = "";
    if params.download_time_sum ~= nil then
        local min_time = tonumber(params.download_time_sum)/(60*1000);
        local show_min_time = string.format("%0.2f", min_time);
        third_title = third_title..LoadStr(ID_TIPS_PREUPDATE_END_2) .. show_min_time .. LoadStr(ID_TIPS_PREUPDATE_END_3);
    end;
    if third_title ~= "" then
        tip_data.third_title = third_title;
    end;
    if params.cur_game_id ~= nil then
        local jump_url="";
        jump_url = '{"type":"landing","game_id":'..params.cur_game_id..'}';
        
        tip_data.win_click_url = jump_url;
    end;
    tip_data.close_service = "i_broadcast_preupdate_result_close";
    tip_data.tips_type_bubble = tip_type_constant.BUBBLE_ICON_TYPE_RECTANGLE;
    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);
    gameupdate_tips_control.add_update_tip(tip_data);
    -- 数据上报
    tip_data.game_id = params.cur_game_id;
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_show", tip_data);
end

function gameupdate_tips_control.on_preupdate_result_close(tip_ret_tbl)

    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gameupdate_tips_control.find_update_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    gameupdate_tips_control.remove_update_tip(tip_ret_tbl.id);
end

-- 自动更新开始事件
function gameupdate_tips_control.on_autoupdate_begin(result)

    if result == nil or result.game_id == nil then
        base_utility.log("[gameupdate_tips_control]on_autoupdate_begin, no game_id");
        return;
    end;
    -- 准备要显示的数据
    local params = {};
    params.current_game_id = result.game_id;
    local base_info = banner_model.get_game_base_info(result.game_id);
    if base_info == nil then        
        base_utility.log("[gameupdate_tips_control]base_info is nil, game_id:" .. result.game_id, true);
        return;
    end;
    params.cur_game_name = base_info.name;
    -- 获得横版海报
    params.cur_game_img_url = base_info.poster_url;
    -- 整理要显示的内容，发送给tips管理器显示
    gameupdate_tips_control.show_autoupdate_begin_tips(params);
end

function gameupdate_tips_control.show_autoupdate_begin_tips(params)
    local tip_data = {};
    tip_data.id = os.time();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_BUBBLE;
    tip_data.tips_sub_type = tip_type_constant.sub_type_autoupdate_begin;
    if params.cur_game_img_url ~= nil then
        tip_data.tips_icon = params.cur_game_img_url;  -- 添加获取的游戏头像
    end;
    
    tip_data.main_title = LoadStr(ID_TIPS_AUTO_UPDATE);
    tip_data.sub_title = params.cur_game_name;
    local third_title = "";
    if params.current_game_id ~= nil then
        local jump_url="";
        jump_url = '{"type":"landing","game_id":'..params.current_game_id..'}';
        
        tip_data.win_click_url = jump_url;
    end;
    tip_data.tips_type_bubble = tip_type_constant.BUBBLE_ICON_TYPE_RECTANGLE;
    tip_data.close_service = "i_broadcast_autoupdate_begin_close";
    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);
    gameupdate_tips_control.add_update_tip(tip_data);
    -- 数据上报
    tip_data.game_id = params.current_game_id;
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_show", tip_data);
end

function gameupdate_tips_control.on_autoupdate_begin_close(tip_ret_tbl)

    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gameupdate_tips_control.find_update_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    gameupdate_tips_control.remove_update_tip(tip_ret_tbl.id);
end

-- 安装完成事件
function gameupdate_tips_control.on_install_finish(result)

    if result == nil or result.game_id == nil then
        base_utility.log("[gameupdate_tips_control]on_install_finish, no game_id");
        return;
    end;
    -- 准备要显示的数据
    local params = {};
    params.current_game_id = result.game_id;
    local base_info = banner_model.get_game_base_info(result.game_id);
    if base_info == nil then        
        base_utility.log("[gameupdate_tips_control]base_info is nil, game_id:" .. result.game_id, true);
        return;
    end;
    params.cur_game_name = base_info.name;
    -- 获得横版海报
    params.cur_game_img_url = base_info.poster_url;
    -- 整理要显示的内容，发送给tips管理器显示
    gameupdate_tips_control.show_install_finish_tips(params);
end

function gameupdate_tips_control.show_install_finish_tips(params)
    local tip_data = {};
    tip_data.id = os.time();
    tip_data.tips_main_type = 1;
    tip_data.tips_sub_type = 3002;
    if params.cur_game_img_url ~= nil then
        tip_data.tips_icon = params.cur_game_img_url;  -- 添加获取的游戏头像
    end;
    
    tip_data.main_title = LoadStr(ID_TIPS_INSTALL_FINISH);
    tip_data.sub_title = params.cur_game_name;
    local third_title = "";
    if params.cur_game_id ~= nil then
        local jump_url="";
        jump_url = '{"type":"landing","game_id":'..params.cur_game_id..'}';
        
        tip_data.win_click_url = jump_url;
    end;
    tip_data.tips_type_bubble = tip_type_constant.BUBBLE_ICON_TYPE_RECTANGLE;
    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);
    gameupdate_tips_control.add_update_tip(tip_data);
     -- 数据上报
     tip_data.game_id = params.current_game_id;
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_show", tip_data);
end

function gameupdate_tips_control.on_install_finish_close(tip_ret_tbl)

    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gameupdate_tips_control.find_update_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    gameupdate_tips_control.remove_update_tip(tip_ret_tbl.id);
end


-- 服务器下发的tips:包括通用tips,想玩tips
server_tip_control = 
{
    TIPS_TYPE_WANTPALY = 5;
    TIPS_TYPE_NORMAL = 0;
    show_server_tip_list = {};
}

function server_tip_control.init()
    comm_center.listen_broadcast("i_broadcast_server_close", server_tip_control.on_server_wantplay_close);
    comm_center.listen_broadcast("i_broadcast_server_click",
        server_tip_control.on_server_wantplay_click);
end

function server_tip_control.add_server_tip(tip_data)
    local cur_length = #(server_tip_control.show_server_tip_list);
    table.insert(server_tip_control.show_server_tip_list,
                    cur_length + 1, tip_data);
end

function server_tip_control.remove_server_tip(tip_id)
    local cur_length = #(server_tip_control.show_server_tip_list);
    local remove_index = 0;
    for index = 1, cur_length do
        local temp_tip_data = server_tip_control.show_server_tip_list[index];
        if temp_tip_data.id == tip_id then
            remove_index = index;
            break;
        end;
    end;
    if remove_index > 0 then
        table.remove(server_tip_control.show_server_tip_list, remove_index);
    end;
end

function server_tip_control.find_server_tip(tip_id)
    local cur_length = #(server_tip_control.show_server_tip_list);
    local find_tip_data = nil;
    for index = 1, cur_length do
        local temp_tip_data = server_tip_control.show_server_tip_list[index];
        if temp_tip_data.id == tip_id then
            find_tip_data = server_tip_control.show_server_tip_list[index];
            break;
        end;
    end;
    return find_tip_data;
end

function server_tip_control.show_server_tips(event_id, params)

    -- 判断是否是launcher启动的wegaeme，如果是，则不显示新手引导
    local is_launcher = base_utility.is_type_of_launcher();
    if is_launcher == true then
        base_utility.log("we game is launched by game, not show server tips");
        return;
    end;

    local info = base_utility.json_to_table(params)

    base_utility.log("[server_tip_control] receive server tips:"..params);

    -- 上报已经收到了tips
    local tips_mgr = base_utility.get_component_adapter("ITIPS_mgr",
                                "ierd_tgp.tips_mgr.GetTipsMgrModule();");
    if poptips_model.tips_mgr ~= nil then
        tips_mgr:SendPopTipsOP((info.tip_id or 0), ierd_tgp.tips_mgr.KIND_TIP_ARRIVE, 0);
    else
        base_utility.log("[server_tip_control] get tips_mgr faild, failed to tell c++, tip_id="..info.tip_id);
    end;
    -- 显示tips
    if info.type == nil then
        base_utility.log("[server_tip_control] get tips type failed, tip_id="..info.tip_id);
        return;
    end;
    server_tip_control.send_server_tips(info);
end

function server_tip_control.send_server_tips(info)
    -- body
    local tip_data = {};
    tip_data.id = tonumber(info.tip_id);
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_NORMAL;
    if info.type == server_tip_control.TIPS_TYPE_WANTPALY then
        tip_data.tips_sub_type = tip_type_constant.sub_type_server_wantplay;
        if info.icon and info.icon ~= "" then
            tip_data.tips_icon = info.icon;
            tip_data.icon_type = tip_type_constant.ICON_TYPE_CIRCULAR;
        end;
    elseif info.type == server_tip_control.TIPS_TYPE_NORMAL then
        tip_data.tips_sub_type = tip_type_constant.sub_type_server_normal;
        if info.icon and info.icon ~= "" then
            tip_data.tips_icon = info.icon;
            tip_data.icon_type = tip_type_constant.ICON_TYPE_SQUARE;
        end;
        tip_data.tips_type_normal = 1;
    end;
    tip_data.main_title = info.descTitle;
    tip_data.sub_title = info.desc;
    if info.title ~= nil and info.title ~= "" then
        tip_data.tips_title = info.title;
    else
        if info.type == server_tip_control.TIPS_TYPE_WANTPALY then
            tip_data.tips_title = LoadStr(ID_TIPS_WANTPLAY_TITLE);
        elseif info.type == server_tip_control.TIPS_TYPE_NORMAL then
            tip_data.tips_title = LoadStr(ID_TIPS_SERVER_NORMAL_TITLE);
        end;
        
    end;
    
    tip_data.tips_ok_btn = LoadStr(ID_TIPS_WANTPLAY_GO);
    tip_data.ok_service = "i_broadcast_server_click";
    tip_data.close_service = "i_broadcast_server_close";
    if info.stay_sec ~= nil and info.stay_sec ~= "" and info.stay_sec ~= 0 then
        tip_data.show_duration = info.stay_sec * 1000;
    else
        -- 对于没有设置自动关闭时长的tips，产品规定到第二天凌晨4点自动关闭
        tip_data.show_duration = server_tip_control.calc_duration_to_nextday_fourhour();
    end;


    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);

    tip_data.click_url = info.link;
     -- 数据上报
     -- 设置要上报的任务ID
    tip_data.task_id = tonumber(info.tip_id);
    server_tip_control.add_server_tip(tip_data);

    tips_reveive_common.tips_qos("wg_common_tip", "client_show", tip_data);
end

function server_tip_control.calc_duration_to_nextday_fourhour()
	local now_date = os.date("*t");
    local today_end_time = os.time({year=now_date.year, month=now_date.month, day=now_date.day, hour=23, min=59, sec=59});
    local seconds_to_nextday = today_end_time - os.time() + 1;
    local seconds_in_four_hour = 4 * 60 * 60;
    local duration = (seconds_to_nextday + seconds_in_four_hour) * 1000;
    return duration;
end

function server_tip_control.on_server_wantplay_close(tip_ret_tbl)
    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = server_tip_control.find_server_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_common_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    server_tip_control.remove_server_tip(tip_ret_tbl.id);
end

function server_tip_control.on_server_wantplay_click(tip_ret_tbl)
    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = server_tip_control.find_server_tip(tip_ret_tbl.id);
    if tip_data ~= nil and tip_data.click_url ~= nil then
        local json_str = tip_data.click_url;
        local json_table = base_utility.json_to_table(json_str);
        if json_table.from ~= nil and json_table.from ~= "" and json_table.game_id ~= nil and tip_data.task_id ~= nil then
           json_table.from = string.format("%s.%d.%u", json_table.from, tip_data.task_id, json_table.game_id);
           json_str = base_utility.table_to_json(json_table);
           base_utility.log("[server_tip_control] on_server_wantplay_click, spliced json_str="..json_str);
        else
           base_utility.log("[server_tip_control] on_server_wantplay_click, json_str="..json_str);
        end
        web_utility.open_link_convert_confirm_launch(json_str);      
    end;
end

function server_tip_control.show_normal_tips(info)
    -- body
end


-- gamelibrary模块发出的通知消息
gamelibrary_message_notify_control = 
{
    -- 直播订阅tips类型
    live_tips_type = 2002;
    video_tips_type = 2003;
    game_tips_type = 2004;
    comm_tips_type = 2006;
    show_notify_tip_list = {};
}

function gamelibrary_message_notify_control.init()
    comm_center.listen_broadcast("i_broadcast_subscribe_close", gamelibrary_message_notify_control.on_subscribe_close);
    comm_center.listen_broadcast("i_broadcast_subscribe_setting",
        gamelibrary_message_notify_control.on_subscribe_setting);
    comm_center.listen_broadcast("i_broadcast_subscribe_watch",
        gamelibrary_message_notify_control.on_subscribe_watch);
    comm_center.listen_broadcast("i_broadcast_subscribe_more",
        gamelibrary_message_notify_control.on_subscribe_more);
    comm_center.listen_broadcast("i_broadcast_gamelib_common_tip_ok",
        gamelibrary_message_notify_control.on_common_tip_ok);
end

function gamelibrary_message_notify_control.add_notify_tip(tip_data)
    local cur_length = #(gamelibrary_message_notify_control.show_notify_tip_list);
    table.insert(gamelibrary_message_notify_control.show_notify_tip_list,
                    cur_length + 1, tip_data);
end

function gamelibrary_message_notify_control.remove_notify_tip(tip_id)
    local cur_length = #(gamelibrary_message_notify_control.show_notify_tip_list);
    local remove_index = 0;
    for index = 1, cur_length do
        local temp_tip_data = gamelibrary_message_notify_control.show_notify_tip_list[index];
        if temp_tip_data.id == tip_id then
            remove_index = index;
            break;
        end;
    end;
    if remove_index > 0 then
        table.remove(gamelibrary_message_notify_control.show_notify_tip_list, remove_index);
    end;
end

function gamelibrary_message_notify_control.find_notify_tip(tip_id)
    local cur_length = #(gamelibrary_message_notify_control.show_notify_tip_list);
    local find_tip_data = nil;
    for index = 1, cur_length do
        local temp_tip_data = gamelibrary_message_notify_control.show_notify_tip_list[index];
        if temp_tip_data.id == tip_id then
            find_tip_data = gamelibrary_message_notify_control.show_notify_tip_list[index];
            break;
        end;
    end;
    return find_tip_data;
end

function gamelibrary_message_notify_control.on_msg_notify(event_id, json_str)
    if base_utility.is_big_picture_ui() then
        return;
    end

    local msg_tbl = base_utility.json_to_table(json_str);
    if msg_tbl == nil or msg_tbl.msg_type == nil then
        base_utility.log("[gamelibrary_message_notify_control] receive notify msg is nil");
        return;
    end;
    if msg_tbl.msg_type == gamelibrary_message_notify_control.live_tips_type or
            msg_tbl.msg_type == gamelibrary_message_notify_control.video_tips_type or
            msg_tbl.msg_type == gamelibrary_message_notify_control.game_tips_type then
        base_utility.log("[gamelibrary_message_notify_control] receive subscribe notify, will show");
        gamelibrary_message_notify_control.show_subscribe_tips(msg_tbl);
    elseif msg_tbl.msg_type == gamelibrary_message_notify_control.comm_tips_type then
        gamelibrary_message_notify_control.show_common_tips(msg_tbl);
    end;
end

function gamelibrary_message_notify_control.show_subscribe_tips(msg_tbl)
    if msg_tbl == nil or type(msg_tbl) ~= "table" then
        return;
    end;
    local tips_type = msg_tbl.msg_type;
    -- local content_tbl = base_utility.json_to_table(msg_tbl.msg_content);
    local content_tbl = base_utility.json_to_table(msg_tbl.msg_content);
    if content_tbl == nil then
        base_utility.log("[gamelibrary_message_notify_control] get msg content is nil, return");
        return;
    end;
    if tips_type == gamelibrary_message_notify_control.live_tips_type then
        -- 直播订阅
        gamelibrary_message_notify_control.show_live_subscrible_tips(content_tbl);
    elseif tips_type == gamelibrary_message_notify_control.video_tips_type then
        -- 栏目订阅
        gamelibrary_message_notify_control.show_video_subscrible_tips(content_tbl);
    elseif tips_type == gamelibrary_message_notify_control.game_tips_type then
        gamelibrary_message_notify_control.show_game_subscrible_tips(content_tbl);
    end;
end

function gamelibrary_message_notify_control.show_live_subscrible_tips(content_tbl)
    local tip_data = {};
    tip_data.id = os.time();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_NORMAL;
    tip_data.tips_sub_type = tip_type_constant.sub_type_live;

    -- 图片url
    if content_tbl.head_url ~= nil and content_tbl.head_url ~= "" then
        tip_data.tips_icon = content_tbl.head_url;
    end;
    tip_data.icon_type = tip_type_constant.ICON_TYPE_CIRCULAR;

    -- tips标题
    local title = "";
    if content_tbl.title ~= nil then
        title = content_tbl.title;
    end;
    tip_data.tips_title = title;

    -- tips主体内容
    local nick_name = "";
    if content_tbl.nick_name ~= nil then
        nick_name = content_tbl.nick_name;
    end;
    local content = "";
    local name_cui, name_hoder;
    if (string.find(nick_name, "[^a-z0-9_]") == nil) then --全小写英文和标点
        name_cui, name_hoder = U8toCUIStrn(nick_name, 15, 1);
    else
        name_cui, name_hoder = U8toCUIStrn(nick_name, 10, 1);
    end
    local name_u8 = CUIStrtoU8(name_cui);
    content = LoadStr(ID_TIPS_LIVE_1)..name_u8..LoadStr(ID_TIPS_LIVE_2);
    tip_data.main_title = content;

    -- tips操作区域
    if content_tbl.live_url ~= nil and content_tbl.live_url ~= "" then
        local param = {};
        param.type = "open_video";
        param.url = content_tbl.live_url;
        param.qblink = true;
        param.width = 1280;
        param.height = 705;
        if content_tbl.width ~= nil and content_tbl.height ~= nil then
            param.width = content_tbl.width;
            param.height = content_tbl.height;
        end
        local json_str = base_utility.table_to_json(param);
        tip_data.win_click_url = json_str;
    end;
    
    local more = "";
    if content_tbl.num ~= nil and content_tbl.num > 0 then
        more = LoadStr(ID_TIPS_LIVE_3)..tostring(content_tbl.num)..LoadStr(ID_TIPS_LIVE_4);
    end;
    if more ~= "" then
        tip_data.tips_cancel_btn = more;
        tip_data.cancel_service = "i_broadcast_subscribe_more";
    end;
    tip_data.tips_ok_btn = LoadStr(ID_TIPS_LIVE_5);
    tip_data.ok_service = "i_broadcast_subscribe_watch";
    -- 设置点击回调
    tip_data.tips_setting = 1;
    tip_data.setting_service = "i_broadcast_subscribe_setting";
    tip_data.show_duration = 30000;
    tip_data.close_service = "i_broadcast_subscribe_close";

    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);

    -- 保存发送的数据
    tip_data.subscribe_type = gamelibrary_message_notify_control.live_tips_type;
    tip_data.jump_url = content_tbl.jump_url;
    tip_data.live_url = content_tbl.live_url;
    gamelibrary_message_notify_control.add_notify_tip(tip_data);

    tips_reveive_common.tips_qos("wg_common_tip", "client_show", tip_data);
end

function gamelibrary_message_notify_control.show_video_subscrible_tips(content_tbl)
    local tip_data = {};
    tip_data.id = os.time();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_NORMAL;
    tip_data.tips_sub_type = tip_type_constant.sub_type_video;

    -- 图片url
    if content_tbl.head_url ~= nil and content_tbl.head_url ~= "" then
        tip_data.tips_icon = content_tbl.head_url;
    end;
    tip_data.icon_type = tip_type_constant.ICON_TYPE_CIRCULAR;

    -- tips标题
    local title = "";
    if content_tbl.title ~= nil then
        title = content_tbl.title;
    end;
    tip_data.tips_title = title;

    -- tips主体内容
    local nick_name = "";
    if content_tbl.nick ~= nil then
        nick_name = content_tbl.nick;
    end;
    local content = "";
    local name_cui, name_hoder;
    if (string.find(nick_name, "[^a-z0-9_]") == nil) then --全小写英文和标点
        name_cui, name_hoder = U8toCUIStrn(nick_name, 15, 1);
    else
        name_cui, name_hoder = U8toCUIStrn(nick_name, 10, 1);
    end
    local name_u8 = CUIStrtoU8(name_cui);
    content = LoadStr(ID_TIPS_LIVE_6)..name_u8..LoadStr(ID_TIPS_LIVE_7);
    tip_data.main_title = content;

    -- tips操作区域
    if content_tbl.player_url ~= nil and content_tbl.player_url ~= "" then
        -- 设置win click的参数
        local param = {};
        param.type = "open_video";
        param.url = content_tbl.player_url;
        param.qblink = true;
        param.width = 1280;
        param.height = 705;
        if content_tbl.width ~= nil and content_tbl.height ~= nil then
            param.width = content_tbl.width;
            param.height = content_tbl.height;
        end
        local json_str = base_utility.table_to_json(param);
        tip_data.win_click_url = json_str;
    end;
    tip_data.tips_ok_btn = LoadStr(ID_TIPS_LIVE_5);
    tip_data.ok_service = "i_broadcast_subscribe_watch";
    -- 设置点击回调
    tip_data.tips_setting = 1;
    tip_data.setting_service = "i_broadcast_subscribe_setting";
    tip_data.close_service = "i_broadcast_subscribe_close";
    tip_data.show_duration = 30000;

    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);

    tip_data.subscribe_type = gamelibrary_message_notify_control.video_tips_type;
    tip_data.jump_url = content_tbl.jump_url;
    tip_data.player_url = content_tbl.player_url;
    gamelibrary_message_notify_control.add_notify_tip(tip_data);

    tips_reveive_common.tips_qos("wg_common_tip", "client_show", tip_data);
end

function gamelibrary_message_notify_control.show_game_subscrible_tips(content_tbl)
    local tip_data = {};
    tip_data.id = os.time();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_NORMAL;
    tip_data.tips_sub_type = tip_type_constant.sub_type_gamelive;

    -- 图片url
    -- if content_tbl.head_url ~= nil and content_tbl.head_url ~= "" then
    --     tip_data.tips_icon = content_tbl.head_url;
    -- end;
    -- tip_data.icon_type = tip_type_constant.ICON_TYPE_CIRCULAR;

    -- tips标题
    local title = "";
    if content_tbl.title ~= nil then
        title = content_tbl.title;
    end;
    tip_data.tips_title = title;

    -- tips主体内容
    local nick_name = "";
    if content_tbl.nick_name ~= nil then
        nick_name = content_tbl.nick_name;
    end;
    local content = "";
    -- local name_cui, name_hoder;
    -- if (string.find(nick_name, "[^a-z0-9_]") == nil) then --全小写英文和标点
    --     name_cui, name_hoder = U8toCUIStrn(nick_name, 15, 1);
    -- else
    --     name_cui, name_hoder = U8toCUIStrn(nick_name, 10, 1);
    -- end
    local name_u8 = content_tbl.nick_name;
    content = LoadStr(ID_TIPS_GAME_LIVE_1)..name_u8..LoadStr(ID_TIPS_GAME_LIVE_2);
    tip_data.main_title = content;

    -- tips操作区域
    local param = {};
    if content_tbl.jump_url ~= nil and content_tbl.jump_url ~= "" then
        param.url = content_tbl.jump_url;
        param.type = "open_web";
        param.browser = "multi_web";
        param.use_ptlogin = "0";

        tip_data.win_click_url = base_utility.table_to_json(param);
    end;
    tip_data.tips_ok_btn = LoadStr(ID_TIPS_LIVE_5);
    tip_data.ok_service = "i_broadcast_subscribe_watch";
    -- 设置点击回调
    tip_data.close_service = "i_broadcast_subscribe_close";
    tip_data.show_duration = 30000;

    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);

    tip_data.subscribe_type = gamelibrary_message_notify_control.game_tips_type;
    
    gamelibrary_message_notify_control.add_notify_tip(tip_data);

    tips_reveive_common.tips_qos("wg_common_tip", "client_show", tip_data);
end

function gamelibrary_message_notify_control.on_subscribe_close(tip_ret_tbl)
    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gamelibrary_message_notify_control.find_notify_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_common_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    gamelibrary_message_notify_control.remove_notify_tip(tip_ret_tbl.id);
end

function gamelibrary_message_notify_control.on_subscribe_setting(tip_ret_tbl)
    -- 打开设置功能
    local param = {};
    param.type = "setting";
    param.sub_page = "ROUTINE_SETTING";
    local json_str = base_utility.table_to_json(param);
    comm_center.call_service(tips_reveive_common.open_link_service, json_str);

    -- 数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gamelibrary_message_notify_control.find_notify_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_common_tip", "client_show", tip_data, tip_ret_tbl);

end

function gamelibrary_message_notify_control.on_subscribe_watch(tip_ret_tbl)
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        base_utility.log("[gamelibrary_message_notify_control] ret tip data, id is nil");
        return;
    end;
    local content_info = gamelibrary_message_notify_control.find_notify_tip(tip_ret_tbl.id);
    if content_info == nil then
        base_utility.log("[gamelibrary_message_notify_control]can't find send tip");
        return;
    end;

    local param = {};
    param.type = "open_video";
    if content_info.subscribe_type == gamelibrary_message_notify_control.live_tips_type then
        param.url = LoadStr("OPEN_VIDEO_URL");
        if content_info.live_url ~= nil then
            param.url = content_info.live_url;
        end;
    elseif content_info.subscribe_type == gamelibrary_message_notify_control.game_tips_type then
        if content_info.win_click_url ~= nil then
            comm_center.call_service(tips_reveive_common.open_link_service, content_info.win_click_url);
            return;
        end;
    elseif content_info.subscribe_type == gamelibrary_message_notify_control.video_tips_type then
        if content_info.player_url ~= nil then
            param.url = content_info.player_url;
        end;
    end;
    param.qblink = true;
    param.width = 1280;
    param.height = 705;
    if content_info.width ~= nil and content_info.height ~= nil then
        param.width = content_info.width;
        param.height = content_info.height;
    end
    local json_str = base_utility.table_to_json(param);
    comm_center.call_service(tips_reveive_common.open_link_service, json_str);
    -- 这里根据返回数据进行数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gamelibrary_message_notify_control.find_notify_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_common_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    gamelibrary_message_notify_control.remove_notify_tip(tip_ret_tbl.id);
end

function gamelibrary_message_notify_control.on_subscribe_more(tip_ret_tbl)
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        base_utility.log("[gamelibrary_message_notify_control] ret tip data, id is nil");
        return;
    end;
    local content_info = gamelibrary_message_notify_control.find_notify_tip(tip_ret_tbl.id);
    if content_info == nil then
        base_utility.log("[gamelibrary_message_notify_control]can't find send tip");
        return;
    end;

    local param = {};
    param.type = "jump_url";
    param.id = GAME_ID.GAME_ID_GAME_LIVE;
    param.url = LoadStr("LIVE_CENTER_FOLLOW_URL");
    if content_info ~= nil and content_info.jump_url ~= nil then
        param.url = content_info.jump_url;
    end
    local json_str = base_utility.table_to_json(param);
    comm_center.call_service(tips_reveive_common.open_link_service, json_str);
    -- 这里根据返回数据进行数据上报
    if tip_ret_tbl == nil or tip_ret_tbl.id == nil then
        return;
    end;
    local tip_data = gamelibrary_message_notify_control.find_notify_tip(tip_ret_tbl.id);
    tips_reveive_common.tips_qos("wg_common_tip", "client_close", tip_data, tip_ret_tbl);
    -- 删除关闭的tip
    gamelibrary_message_notify_control.remove_notify_tip(tip_ret_tbl.id);
end

game_banner_tips_control = {
    
};

function game_banner_tips_control.init()
    comm_center.reg_service("i_service_show_subscription_notify_tips", "game_banner_tips_control.on_subscription_state_changed");
end

function game_banner_tips_control.on_subscription_state_changed(params)
    local tip_data = {};
    tip_data.id = os.time();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_BUBBLE;
    tip_data.tips_sub_type = tip_type_constant.sub_type_subscription_state;
    if params.game_img_url ~= nil then
        tip_data.tips_icon = params.game_img_url;
    end;
    
    tip_data.main_title = params.main_title or "";
    tip_data.sub_title = params.game_name;
    tip_data.third_title = string.format('<f c="0x00abfa">%s</f>', params.third_title);
    tip_data.show_duration = 15000;
    if params.game_id ~= nil then
        local jump_url = "";
        if "purchase" == params.game_action then
            jump_url = '{"type":"mmo_game","sub_page":"GAME_DETAIL","game_id":'..params.game_id..'}';
        elseif "download" == params.game_action then
            jump_url = '{"type":"download","game_id":'..params.game_id..'}';
        elseif "play" == params.game_action then
            jump_url = '{"type":"launch_game","game_id":'..params.game_id..', "server_id":"0", "op_from":"0"}';
        elseif "landing" == params.game_action then
            jump_url = '{"type":"landing","game_id":'..params.game_id..'}';
        end
        tip_data.third_title_url = jump_url;
    end;
    tip_data.tips_type_bubble = tip_type_constant.BUBBLE_ICON_TYPE_RECTANGLE;
    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);

    tip_data.game_id = params.game_id;
    tips_reveive_common.tips_qos("wg_bubble_tip", "client_show", tip_data);
end;

function gamelibrary_message_notify_control.generate_tip_id()
    local id = os.time()
    while nil ~= gamelibrary_message_notify_control.find_notify_tip(id) do
        id = id + 1;
    end
    return id;
end

function gamelibrary_message_notify_control.show_common_tips(msg_tbl)
    if nil == msg_tbl or nil == msg_tbl.msg_content or "" == msg_tbl.msg_content then
        return;
    end
    local tip_param = base_utility.json_to_table(msg_tbl.msg_content);
    if nil == tip_param or base_utility.is_empty_table(tip_param) then
        return;
    end
    
    -- general settings
    local show_duration = 30;
    if nil ~= tip_param.show_duration then
        show_duration = tonumber(tip_param.show_duration);
    end

    if show_duration > 0 then
        show_duration = show_duration * 1000;
    end

    -- title area
    local title_area = tip_param.title_area or {};
    local tip_title = title_area.data or "";
    
    -- content area
    local content_area = tip_param.content_area or {};
    local tip_content = content_area.data or "";
    local tip_sub_content = content_area.sub_data;

    -- icon area
    local icon_area = tip_param.icon_area or {};
    local tip_icon = icon_area.icon_url; -- url(string) or game id(number)

    -- button area
    local ok_btn_caption = LoadStr("ID_TPF_OK");
    local button_area = tip_param.button_area or {};
    if #button_area > 0 then
        local ok_button_area = button_area[1];
        if nil ~= ok_button_area.name and "" ~= ok_button_area.name then
            ok_btn_caption = ok_button_area.name;
        end
    end

    local tip_data = {};
    tip_data.id = gamelibrary_message_notify_control.generate_tip_id();
    tip_data.tips_main_type = tip_type_constant.MAIN_TYPE_NORMAL;
    tip_data.tips_sub_type = tip_type_constant.sub_type_server_normal;
    tip_data.tips_title = tip_title;
    tip_data.tips_icon = tip_icon;
    tip_data.main_title = tip_content;
    tip_data.sub_title = tip_sub_content;
    tip_data.tips_ok_btn = ok_btn_caption;
    tip_data.ok_service = "i_broadcast_gamelib_common_tip_ok";
    tip_data.show_duration = show_duration;
    comm_center.send_broadcast("i_broadcast_tips_show_com", tip_data);
    tip_data.raw_param = tip_param;
    gamelibrary_message_notify_control.add_notify_tip(tip_data);
    tips_reveive_common.tips_qos("wg_common_tip_v2", "client_show", tip_data);
end;

function gamelibrary_message_notify_control.on_common_tip_ok(args)
    if nil == args or nil == args.id then
        base_utility.log("[gamelibrary_message_notify_control]common tip, null ret tip data", true);
        return;
    end;
    local tip_data = gamelibrary_message_notify_control.find_notify_tip(args.id);
    if nil == tip_data or nil == tip_data.raw_param then
        base_utility.log("[gamelibrary_message_notify_control]common tip, no id", true);
        return;
    end;

    local btn_action = {};
    local button_area = tip_data.raw_param.button_area or {};
    if #button_area > 0 then
        local ok_button_area = button_area[1];
        btn_action = ok_button_area.action or {};
    end

    local action_param = btn_action.params or {};
    if btn_action.type == "call_service" then
        comm_center.call_service(action_param.action_name, action_param);
    elseif btn_action.type == "send_broadcast" then
        comm_center.send_broadcast(action_param.action_name, action_param);
    else
        action_param.type = btn_action.type;
        comm_center.call_service("i_service_open_link", action_param);
    end
    gamelibrary_message_notify_control.remove_notify_tip(args.id);
end;

gameupdate_tips_control.init();
server_tip_control.init();
gamelibrary_message_notify_control.init();
game_banner_tips_control.init();
